/********************************************************************
 * COPYRIGHT --  
 ********************************************************************
 * Program: 
 * File: .c
 * Author: Liubaiyan
 * Created: 2019.09.03
 ********************************************************************
 * Implementation of program RcpUser
 * V1.00  ---  
 ********************************************************************/
#include <bur/plctypes.h>

#ifdef _DEFAULT_INCLUDES
	#include <AsDefault.h>
#endif

void _INIT ProgramInit(void)
{
	// Insert code here 

}

void _CYCLIC ProgramCyclic(void)
{
	gWndComm.Output.RewinderCurDia = gWndCtrl.Status.ReCurDia;
	gWndComm.Output.RewinderCurTen = gWndIO.Rewinder.aoDancerTension;
//	gWndComm.Output.UnCurAx = gWndCtrl.Status.UnCurAx;
//	gWndComm.Output.Un2CurAx = gWndCtrl.Status.Un2CurAx;
//	gWndComm.Output.ReCurAx = gWndCtrl.Status.ReCurAx;
	
	if (gWndPara.Tension.MaterialTensionMax <= 0)
		gWndPara.Tension.MaterialTensionMax = 500.0f;
	//gWndIO.Unwinder.aoDancerTension = gWndPara.Tension.MaterialTension[0] / gWndPara.Tension.MaterialTensionMax * 32767.0f;
	//gWndIO.Unwinder2.aoDancerTension = gWndPara.Tension.MaterialTension[1] / gWndPara.Tension.MaterialTensionMax * 32767.0f;
	//gWndIO.Rewinder.aoDancerTension = gWndPara.Tension.MaterialTension[2] / gWndPara.Tension.MaterialTensionMax * 32767.0f * (gWinderCurveCtrl.outputPercent / 10) / 100.0f;
	
	for (WndIndex = 0; WndIndex < 3; WndIndex++)
	{
		if (gWndCtrl.ComDancer.DancerPercent[WndIndex*2] > 0)
		{
			hmiDancerPos[WndIndex] = gWndCtrl.ComDancer.DancerPercent[WndIndex*2];
			hmiDancerNeg[WndIndex] = 0;
		}
		else
		{
			hmiDancerPos[WndIndex] = 0;
			hmiDancerNeg[WndIndex] = 0 - gWndCtrl.ComDancer.DancerPercent[WndIndex*2];
		}
	}
}

void _EXIT ProgramExit(void)
{
	// Insert code here 

}

